import axios from "axios";

// 版本检查
export const versionCheck = async () => {
  if (import.meta.env.VITE_APP_ENV === "development") return;

  const response = await axios.get("version.json");
  console.log(
    "当前版本:",
    process.env.VITE__APP_VERSION__,
    "------线上最新版本:",
    response.data.version,
    "------版本是否一致:",
    process.env.VITE__APP_VERSION__ === response.data.version
  );
  //process.env.VITE__APP_VERSION__  获取环境变量设置的值，判断是否与生成的版本信息一致
  if (response.data.version && process.env.VITE__APP_VERSION__ !== response.data.version) {
    setTimeout(() => {
      window.location.reload();
    }, 200);
  }
};
